package com.szcinda.call.sms;

import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.sms.v20190711.SmsClient;
import com.tencentcloudapi.sms.v20190711.models.SendSmsRequest;
import com.tencentcloudapi.sms.v20190711.models.SendSmsResponse;

//导入可选配置类
// 导入对应SMS模块的client
// 导入要请求接口对应的request response类

public class SendSms {

    public static void send(String phone, String number) {
        phone = "+86" + phone;
        try {
            Credential cred = new Credential("AKIDsjLgkYsYibKo46wWxFHelbEbjOjrdwve", "czACajmcSOF1e7kD8qJWUCg392UmpjU6");
            ClientProfile clientProfile = new ClientProfile();
            clientProfile.setSignMethod("HmacSHA256");
            SmsClient client = new SmsClient(cred, "", clientProfile);
            SendSmsRequest req = new SendSmsRequest();
            String appid = "1400511617";
            req.setSmsSdkAppid(appid);
            String sign = "鹏启物流";
            req.setSign(sign);
            String templateID = "939283";
            req.setTemplateID(templateID);
            String[] phoneNumbers = {phone};
            req.setPhoneNumberSet(phoneNumbers);
            String[] templateParams = {"百世快递", number, "百世快递"};
            req.setTemplateParamSet(templateParams);
            SendSmsResponse res = client.SendSms(req);
            System.out.println(SendSmsResponse.toJsonString(res));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    public static void send(String phone, int type) {
        phone = "+86" + phone;
        try {
            Credential cred = new Credential("AKIDsjLgkYsYibKo46wWxFHelbEbjOjrdwve", "czACajmcSOF1e7kD8qJWUCg392UmpjU6");
            ClientProfile clientProfile = new ClientProfile();
            clientProfile.setSignMethod("HmacSHA256");
            SmsClient client = new SmsClient(cred, "", clientProfile);
            SendSmsRequest req = new SendSmsRequest();
            String appid = "1400511617";
            req.setSmsSdkAppid(appid);
            req.setSign("先达数据助手");
            String[] phoneNumbers = {phone};
            req.setPhoneNumberSet(phoneNumbers);
            if (type == 0) {
                req.setTemplateID("993884");
            } else {
                req.setTemplateID("993907");
            }
            SendSmsResponse res = client.SendSms(req);
            System.out.println(SendSmsResponse.toJsonString(res));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    public static void main(String[] args) {
        /*try {
            Credential cred = new Credential("AKIDsjLgkYsYibKo46wWxFHelbEbjOjrdwve", "czACajmcSOF1e7kD8qJWUCg392UmpjU6");
            ClientProfile clientProfile = new ClientProfile();
            clientProfile.setSignMethod("HmacSHA256");
            SmsClient client = new SmsClient(cred, "", clientProfile);
            SendSmsRequest req = new SendSmsRequest();
            String appid = "1400511617";
            req.setSmsSdkAppid(appid);
            String sign = "鹏启物流";
            req.setSign(sign);
            String templateID = "939283";
            req.setTemplateID(templateID);
            String[] phoneNumbers = {"+8613112274760"};
            req.setPhoneNumberSet(phoneNumbers);
            String[] templateParams = {"测试", "测试", "测试"};
            req.setTemplateParamSet(templateParams);
            SendSmsResponse res = client.SendSms(req);
            System.out.println(SendSmsResponse.toJsonString(res));
        } catch (Exception e) {
            e.printStackTrace();
        }*/
    }
}
